//
//  ViewController.h
//  wtChart
//
//  Created by yuklng on 16/3/1.
//  Copyright © 2016年 yuklng. All rights reserved.
//

#import "ViewController.h"

#import "touchView.h"

#import "scrollTouchView.h"

#define _width [UIScreen mainScreen].bounds.size.width
#define _height [UIScreen mainScreen].bounds.size.height

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    CAGradientLayer* caGradientLayer = [CAGradientLayer layer];
    caGradientLayer.frame = self.view.bounds;
    //添加CAGradientLayer到self.view
    [self.view.layer addSublayer:caGradientLayer];
    //设置渐变起点和终点
    caGradientLayer.startPoint = CGPointMake(0.5, 0);
    caGradientLayer.endPoint = CGPointMake(0.5, 1);
    //设置渐变起始颜色和终止颜色
    UIColor* colorTop = [self ColorFromArgb:0xff6dd9f8];
    UIColor* colorBottom = [self ColorFromArgb:0xffd7c56e];
    caGradientLayer.colors = @[(__bridge id)colorTop.CGColor,(__bridge id)colorBottom.CGColor];
    
//  方法一
    scrollTouchView* touchView =[[scrollTouchView alloc] initWithScopeOrData:CGRectMake(0, 20, _width, (_height-20)/1.5) max:27 min:17 dataArray:@[@"18",@"20",@"25",@"27",@"21",@"24",@"22"]];
    [self.view addSubview:touchView];
    
    [touchView setDelegate:self];
    
    [touchView getListData:3];
    NSLog(@"获取第3个对象数值:%d",[touchView getListData:4]);
    
//  方法二
//    scrollTouchView* touchView2 =[[scrollTouchView alloc] initWithFrame:CGRectMake(0, 20, _width, _height-20)];
//    [touchView2 setMaxRange:99 minRange:86];
//    [touchView2 setDataArray:@[@"99",@"89",@"92"]];
//    [self.view addSubview:touchView2];
    
}

//代理获取数据
-(void)touchSwitch:(BOOL)choice dataArray:(NSArray*)dataArray{
    NSLog(@"代理事件触发");
    NSLog(@"获得当前数据数组:%@",dataArray);
}

//渐变色彩调整
-(UIColor*)ColorFromArgb:(int)argb{
    CGFloat blue = (argb & 0xff)/255.0;
    CGFloat green = (argb >> 8 & 0xff)/255.0;
    CGFloat red = (argb >> 16 & 0xff)/255.0;
    CGFloat alpha = (argb >> 24 & 0xff)/255.0;
    return [UIColor colorWithRed:red green:green blue:blue alpha:alpha];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
